<!-- 工程管理 -->
<template>
  <a-card :bordered="false" class="card-area">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <!-- 搜索区域 -->
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :md="6" :sm="8">
            <a-form-item label="工点名称" :labelCol="{ span: 5 }" :wrapperCol="{ span: 18, offset: 1 }">
              <a-input placeholder="请输入工点名称查询" v-model="queryParam.pointName"></a-input>
            </a-form-item>
          </a-col>

          <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
            <a-col :md="6" :sm="24">
              <a-button type="primary" @click="searchQuery(1)">查询</a-button>
              <a-button style="margin-left: 8px" @click="searchReset">重置</a-button>
            </a-col>
          </span>
        </a-row>
      </a-form>
    </div>
    <!-- 操作按钮区域 -->
    <div class="table-operator" style="margin-top: 0px">
      <a-button v-if="btnEnableList.indexOf(1) > -1" @click="myHandleAdd" type="primary" icon="plus">新增</a-button>
    </div>
    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource1"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
        @change="handleTableChange"
      >
        <span slot="action" slot-scope="text, record">
          <a @click="onClick(record)">查看</a>
          <a-divider v-if="btnEnableList.indexOf(1) > -1" type="vertical" />

          <a v-if="btnEnableList.indexOf(1) > -1" @click="myHandleEdit(record)">编辑</a>
          <a-divider v-if="btnEnableList.indexOf(1) > -1" type="vertical" />
          <a-popconfirm v-if="btnEnableList.indexOf(1) > -1" title="确定删除吗?" @confirm="() => onDelete(record.id)">
            <a>删除</a>
          </a-popconfirm>
        </span>
      </a-table>
    </div>
    <!-- table区域-end -->
    <!-- 表单区域 -->

    <project-manage-modal ref="modalForm" @ok="modalFormOk" :id='id' ></project-manage-modal>
    <modalIndex ref="modalIndex"   v-if="visible"  :id='id' :ids="ids" :visible="visible" @guanbi="guanbi"  @showOrderDetail="showOrderDetail" />
    <bill-detail ref="modalDetail"></bill-detail>
  </a-card>
</template>
<script>
import projectManageModal from './addConstructionsSiteModal'
import modalIndex from './detailConstructionsSiteModal'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { BillListMixin } from '../../bill/mixins/BillListMixin'
import JDate from '@/components/jeecg/JDate'
import { findManageList, deleteGd } from '@/api/api'
import Vue from 'vue'
import BillDetail from '../../bill/dialog/BillDetail'
export default {
  name: 'projectManage',
  mixins: [JeecgListMixin, BillListMixin],

  components: {
    projectManageModal,
    JDate,
    modalIndex,
    BillDetail,
  },
  props: ['id'],
  data() {
    return {
      ids: '',
      visible: false,
      gdid: '',
      // 查询条件
      dataSource1: [],
      queryParam: {
        materialParam: '',
        pointName: '',
        searchMaterial: '',
        type: '其它',
        subType: '销售订单',
        roleType: Vue.ls.get('roleType'),
      },
      labelCol: {
        xs: { span: 24 },
        sm: { span: 8 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 },
      },
      // 表头
      columns: [
        { title: '工点ID', dataIndex: 'id', width: 140 },
        { title: '工点名称', dataIndex: 'name', width: 140 },
        { title: '工点位置', dataIndex: 'address', width: 140 },
        { title: '订单数量', dataIndex: 'commodityTotal', width: 140 },
        { title: '订单总金额', dataIndex: 'allSumPrice', width: 145 },

        // { title: '金额合计', dataIndex: 'totalPrice',width:80},
        // {title: '状态', dataIndex: 'status', width: 70, align: "center",
        //   scopedSlots: { customRender: 'customRenderStatus' }
        // },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          width: 150,
          scopedSlots: { customRender: 'action' },
        },
      ],
      url: {
        list: '/depotHead/list',
        delete: '/depotHead/delete',
        deleteBatch: '/depotHead/deleteBatch',
        batchSetStatusUrl: '/depotHead/batchSetStatus',
      },
    }
  },

  created() {
    this.removeStatusColumn()
    this.manageList()
  },
  computed: {

  },
  methods: {
    showOrderDetail(record) {
      console.log('showOrderDetail','asdasd')
      this.myHandleDetail(record, '销售出库');
    },

    guanbi() {
      this.visible = false
      this.searchQuery(1);
    },
    searchReset() {
      console.log('searchReset', 9999999999999999)
      this.queryParam = {
        type: this.queryParam.type,
        subType: this.queryParam.subType
      }
      this.searchQuery(1);
    },
    onClick(record) {
      this.ids = record.id
      this.visible = true
      // this.$nextTick(() => {
      //   this.$refs.modalIndex.init()
      // })
    },
    // 列表数据
    manageList() {
      findManageList({
        currentPage: 1,
        pageSize: 10,
        engineeringId: this.id,
      }).then((res) => {
        if (res.code === 0) {
          this.dataSource1 = res.data.row
          this.ipagination.total = res.data.total
        }
      })
    },
    onDelete(record) {
      deleteGd({
        id: record,
      }).then((res) => {
        if (res.code === 0) {
          this.manageList()
          this.$message.success('删除成功')
          // this.reload()
        } else {
          this.$message.warning(res.message)
        }
      })
    },
    // 分页事件
    handleTableChange(e){
      console.log('searchQuery', 9999999999999999)
      this.ipagination.current = e.current
      this.searchQuery(e.current)

    },
    searchQuery (currentPage=1,pageSize=10){
      findManageList({
        currentPage,
        pageSize,
        engineeringId: this.id,
        pointName:  this.queryParam.pointName,
      }).then((res) => {

        console.log('searchQuery', 8888)

        if (res.code === 0) {
          // this.dataSource1 = res.data.row
          // this.ipagination.total = res.data.total

          this.$message.success('数据加载成功')
          this.dataSource1 = res.data.row
          this.ipagination.total = res.data.total

        }else {
          this.$message.success('数据加载失败')
        }
      })
    }
    ,
    fatherMethodRefresh(){
      console.log('fatherMethodRefresh', 9999999999999999)
      this.searchQuery(1);
    }
    },


}
</script>
<style scoped>
</style>


